package com.wg.net.operations.base;

import com.wg.core.io.IBinaryReader;
import com.wg.core.io.IBinaryWriter;
import com.wg.core.io.IBinaryWritable;

/**
 * @author 少爷123
 */
public class S2SOperationRequest extends OperationRequest {
    private int id;

    public S2SOperationRequest() {
    }

    public S2SOperationRequest(short opCode) {
        super(opCode);
    }

    public S2SOperationRequest(short opCode, byte[] buffer) {
        super(opCode, buffer);
    }

    public S2SOperationRequest(short opCode, IBinaryWritable contract) {
        super(opCode, contract.toBytes());
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Override
    public void read(IBinaryReader reader) {
        id = reader.readInt();
        super.read(reader);
    }

    @Override
    public void write(IBinaryWriter writer) {
        writer.writeInt(id);
        super.write(writer);
    }

    @Override
    public String toString() {
        return "requestId=" + id + ", requestCode=" + opCode;
    }
}
